package com.bookmanager.www.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bookmanager.www.entity.FlAddress;
import com.bookmanager.www.entity.FlMenu;
import com.bookmanager.www.entity.end.EndMenu;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: 风离
 * @Date: 2021/11/20/0:28
 * @Description:
 */
public interface FlMenuMapper extends BaseMapper<FlAddress> {

    /**
     * 根据角色id获取一级菜单列表
     * @param roleId
     * @return
     */
    List<FlMenu> getMenuListByRoleId(@Param("roleId")Integer roleId);

    /**
     * 根据父菜单id获取二级菜单列表
     * @param menuId
     * @return
     */
    List<FlMenu> getMenuListByFatherId(@Param("father_id") Integer menuId);

    /**
     * 根据角色id获取一级菜单列表
     * @param roleId
     * @return
     */
    List<EndMenu> selectEndMenuListByRoleId(@Param("roleId")Integer roleId);

    /**
     * 根据父菜单id获取二级菜单列表
     * @param id
     * @return
     */
    List<EndMenu> selectMenuListByFatherId(@Param("parent_id") Integer id);

    /**
     * 更新菜单项
     * @param endMenu
     * @return
     */
    int updateMenuItem(@Param("endMenu") EndMenu endMenu);

    /**
     * 根据订单id删除某个菜单项
     * @param id
     * @return
     */
    int deleteMenuItem(@Param("id") Integer id);

    /**
     * 根据菜单id获取父菜单id
     * @param id
     * @return
     */
    int selectParentIdByMenuId(@Param("id")Integer id);

    /**
     * 添加菜单项 默认只添加二级菜单
     * @param endMenu
     * @return
     */
    int insertMenuItem(@Param("endMenu")EndMenu endMenu);

    /**
     * 超级管理员给其他管理员分配菜单
     * @param menuId
     * @param roleId
     * @return
     */
    int allocateResources(@Param("menuId") String menuId,@Param("roleId") Integer roleId);

    /**
     * 根据角色id删除所关联的菜单
     * @param roleId
     * @return
     */
    int deleteResourcesByRoleId(@Param("roleId") Integer roleId);
}
